<?php
/* 
 * I18n控制器
 */
class AclMainController extends LZ_Controller{

	/**
	 * 入口動作
	 */
	public function Action_Index(){
		$v['user'] = isset($_SESSION['user']) ? $_SESSION['user'] : 'anonymous';
		$v['message'] = isset($_SESSION['message']) ? $_SESSION['message'] : null;
		$this->view()->render($v);
		unset($_SESSION['message']);
	}

	/**
	 * 登入
	 */
	public function Action_Signin(){
		$success = false;
		$users = array(
			'member' => '1234',
			'vip' => '1234'
		);
		
		if(isset($_POST['account']) && isset($_POST['password'])){
			if(isset($users[$_POST['account']])){
				if($users[$_POST['account']] === $_POST['password']){
					$_SESSION['user'] = $_POST['account'];
					$success = true;
				}
			}
		}

		if(true === $success){
			$_SESSION['message'] = "登入 {$_GET['account']} 身分成功！";
		}else{
			$_SESSION['message'] = "登入失敗";
		}
		
		app::redirectUrl('/');
	}

	/**
	 * 登出
	 */
	public function Action_Signout(){
		session_start();
		unset($_SESSION['user']);
		app::redirectUrl('/');
	}

}